package com.smartian.scan.filesearch.filters;

import com.smartian.scan.filesearch.interfaces.IFilter;

import java.io.File;
import java.util.HashSet;
import java.util.Set;

public class RepeatFileFilter implements IFilter {

    private final Set<String> PATH_SET = new HashSet<>();

    public synchronized void addPathToDataSet(File file){
        if(file==null ) return;
        PATH_SET.add(file.getAbsolutePath());
    }

    @Override
    public synchronized boolean isAcceptable(File file) {
        return !PATH_SET.contains(file.getAbsolutePath());
    }

    public void release() {
        PATH_SET.clear();
    }
}
